const Koa = require('koa')
const cors = require('koa-cors')
const Router = require('koa-Router')
const body = require('koa-body-parser')
const Mock = require('mockjs')
const data = Mock.mock({
  "list|5": [{
    'id|+': 1,
    'title': '@cname',
    'img':'image(70x70,@color)',
    'children|8': [{
      'id|+': 1,
      'title': '@cname',
    }]
  }]
})


const app = new Koa()
const router = new Router()
router.get('/api/list', (ctx) => {
  ctx.body={
    code:200,
    msg:'获取数据',
    data:data
  }
})
console.log(data);
app.use(body())
app.use(cors())
app.use(router)
app.listen(3000, () => {
  console.log('服务端启动成功');
})